#include <aphw/Transaction.hpp>

#include <boost/python.hpp>
#include <ham/hamsterdb.h>

#include <aphw/Database.hpp>

using namespace boost::python;

namespace
{

ham_status_t begin_txn(aphw::Database& db,
                       ham_u32_t flags)
{
    return ham_txn_begin(db.txn(), 
                         db.db(),
                         flags);
}

ham_status_t commit_txn(aphw::Database& db)
{
    return ham_txn_commit(*db.txn(), 0);
}

ham_status_t abort_txn(aphw::Database& db)
{
    return	ham_txn_abort(*db.txn(), 0);
}

}

namespace aphw
{

void init_Transaction()
{
    def("begin_txn", :: begin_txn);
    def("commit_txn", ::commit_txn);
    def("abort_txn", ::abort_txn);
}

}
